<?php
/**
 * Filename:	GAxisStyleLabel.php
 * Author:		Manish Sinha
 * Date:		24/01/09
 * Details:		This file contains the class GAxisStyleLabel which
 * 				contains information about Axis Styling and Labels for
 * 				line charts,bar charts,radar charts and scatter plots.
 * Project:		GeeCharts
 */

class GAxisStyleLabel
{
	protected $axisTypeSet = array( "BOTTOM" => false,
									"LEFT" => false,
									"RIGHT" => false,
									"TOP" => false);
	
	protected $axisId = array( "BOTTOM" => "x",
								"LEFT" => "y",
								"RIGHT" => "r",
								"TOP" => "t");
								
	protected $axisVal = array( "BOTTOM" => 0,
								"LEFT" => 1,
								"RIGHT" => 2,
								"TOP" => 3);
								
	protected $axisLabels = array();
	protected $axisRange = array();
	protected $labelPos = array();
	
	public function SetAxisType($axistype)
	{
		foreach ($axistype as $tp)
		{
			$this->axisTypeSet[$tp] = true;
		}
		
		return $this;
	}
	
	public function RemoveAxisType($axistype)
	{
		foreach ($axistype as $tp)
		{
			$this->axisTypeSet[$tp] = false;
		}
		
		return $this;
	}
	
	public function SetAxisLabels($axis,$labels)
	{
		$this->axisLabels[$this->axisVal[$axis]] = $labels;
		return $this;
	}
	
	public function RemoveAxisLabels($axis)
	{
		unset($this->axisLabels[$this->axisVal[$axis]]);
		return $this;
	}
	
	public function SetAxisRange($axis,$start,$end,$range = null)
	{
		if($range == null)
		{
			$this->axisRange[$this->axisVal[$axis]] = array($start,$end);
		}
		else
		{
			$this->axisRange[$this->axisVal[$axis]] = array($start,$end,$range);
		}
		
		return $this;
	}
	
	public function RemoveAxisRange($axis)
	{
		unset($this->axisRange[$this->axisVal[$axis]]);
		return $this;
	}

	public function SetLabelPos($axis,$pos)
	{
		$this->labelPos[$this->axisVal[$axis]] = $pos;
		return $this;
	}
	
	public function RemoveLabelPos($axis)
	{
		unset($this->labelPos[$this->axisVal[$axis]]);
		return $this;
	}
	
	public function GetAxisURI()
	{
		$tmparray = array();
		$tmp = array();
		
		foreach($this->axisTypeSet as $key => $axs)
		{
			if($axs == true)
			{
				array_push($tmp,$this->axisId[$key]);
			}
		}
		$tmparray['chxt']= "chxt=".implode(",",$tmp);
		
		if(count($this->axisLabels) != 0)
		{
			$tmp = array();
			foreach($this->axisLabels as $key => $val)
			{
				$tmpstr = $key.":|".implode("|",$val);
				array_push($tmp,$tmpstr);
			}
			$tmparray['chxl'] = "chxl=".implode("|",$tmp);
		}
		
		if(count($this->axisRange) != 0)
		{
			$tmp = array();
			foreach($this->axisRange as $key => $val)
			{
				$tmpstr = $key.",".implode(",",$val);
				array_push($tmp,$tmpstr);
			}
			$tmparray['chxr'] = "chxr=".implode("|",$tmp);
		}
		
		if(count($this->labelPos) != 0)
		{
			$tmp = array();
			foreach($this->labelPos as $key => $val)
			{
				$tmpstr = $key.",".implode(",",$val);
				array_push($tmp,$tmpstr);
			}
			$tmparray['chxp'] = "chxp=".implode("|",$tmp);
		}
		
		return $tmparray;
	}
}
?>
